package com.mall.service.mallLogs.mapper;

import com.mall.model.domain.Timeoutlog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface TimeoutlogMapper {
    //查询数据库规定时间是否有相同的数据
    @Select("SELECT\n" +
            "  *\n" +
            "FROM\n" +
            "  `timeoutlog`\n" +
            "WHERE methodUrl LIKE #{methodUrl}\n" +
            "  AND method like #{method}\n" +
            "  AND startendtime LIKE #{startendtime}")
    Timeoutlog select(String methodUrl, String method, String startendtime);

    //保存超时信息
    @Insert("INSERT INTO `timeoutlog` (\n" +
            "  methodUrl,\n" +
            "  method,\n" +
            "  isTimeout,\n" +
            "  countTimeout,\n" +
            "  startendtime\n" +
            ")\n" +
            "VALUES\n" +
            "  (\n" +
            "    #{methodUrl},\n" +
            "    #{method},\n" +
            "    #{isTimeout},\n" +
            "    #{countTimeout},\n" +
            "    #{startendtime}\n" +
            "  )")
    void save(Timeoutlog timeoutlog);

    //更新
    @Update("UPDATE\n" +
            "  `timeoutlog`\n" +
            "SET\n" +
            "  countTimeout = #{countTimeout}\n" +
            "WHERE id = #{id}")
    void update(Integer countTimeout, Integer id);
}
